<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>分类列表</title>
<link rel="stylesheet" href="static/lib/layui/css/layui.css">
<script type="text/javascript" src="static/lib/layui/layui.js"></script>
<script src="static/js/boUtil.js"></script>
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
<ul id="demo"></ul>


<script type="text/javascript">
/* 获取分类列表 */
$.ajax({
		url : "itemCat/getmenuList",
		success : function(data) {
			var nodes = data.data.nodes;
			//console.log("获取分类列表数据nodes-->"+nodes)
			layui.use('tree', function(){
				
				var tree = layui.tree({
				    elem: '#demo' // 指定元素
				    //,check: 'checkbox' //勾选风格
				    ,skin: 'as' //设定皮肤
				    //,target: '_blank' //是否新选项卡打开（比如节点返回href才有效）
				    ,drag: true
				    ,click: function(item){ //点击节点回调
				    	if(item.isParent && item.children.length > 0) {
				    		layui.use('layer', function(){
				    			  var layer = layui.layer;
				    			  layer.msg('请选择一个正确的分类');
				    			});  
				    		return ;
				    	}
				    	var index = parent.layer.getFrameIndex(window.name);
				    	parent.layer.close(index);
				    	//为上一层页面赋值
				    	parent.$("#catContent").text(item.name);
				    	parent.$("#cid").val(item.id);
				    }
				    ,nodes:nodes
				  });
				
			});
			
			
		}
	});
	
</script>


</body>
</html>